//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.lyyzoo.data.domain;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class Page<T> implements Serializable {
    private static final long serialVersionUID = 5348377138594416030L;
    private final List<T> content;
    private int page;
    private int size;
    private long total;
    private int totalPages;
    private boolean hasNext;
    private boolean hasPrevious;

    public Page() {
        this.content = new ArrayList();
        this.page = 1;
        this.size = 15;
    }

    public Page(List<T> content) {
        this(content, 1, 15, null == content ? 0L : (long)content.size());
    }

    public Page(List<T> content, int page, int size) {
        this(content, page, size, (long)content.size());
    }

    public Page(List<T> content, int page, int size, long total) {
        this.content = new ArrayList();
        this.page = 1;
        this.size = 15;
        this.content.addAll(content);
        if (page < 0) {
            throw new IllegalArgumentException("Page index must not be less than zero!");
        } else if (size < 1) {
            throw new IllegalArgumentException("Page size must not be less than one!");
        } else {
            this.page = page;
            this.size = size;
            this.total = total;
        }
    }

    public int getPage() {
        return this.page;
    }

    public int getSize() {
        return this.size;
    }

    public boolean hasNext() {
        return this.getPage() + 1 < this.getTotalPages();
    }

    public boolean hasPrevious() {
        return this.getPage() > 0;
    }

    public int getTotalPages() {
        this.totalPages = this.getSize() == 0 ? 1 : (int)Math.ceil((double)this.total / (double)this.getSize());
        return this.totalPages;
    }

    public List<T> getContent() {
        return this.content;
    }

    public long getTotal() {
        return this.total;
    }

    public boolean isHasNext() {
        return this.hasNext;
    }

    public boolean isHasPrevious() {
        return this.hasPrevious;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public void setHasNext(boolean hasNext) {
        this.hasNext = hasNext;
    }

    public void setHasPrevious(boolean hasPrevious) {
        this.hasPrevious = hasPrevious;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Page)) {
            return false;
        } else {
            Page<?> other = (Page)o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                label47: {
                    Object this$content = this.getContent();
                    Object other$content = other.getContent();
                    if (this$content == null) {
                        if (other$content == null) {
                            break label47;
                        }
                    } else if (this$content.equals(other$content)) {
                        break label47;
                    }

                    return false;
                }

                if (this.getPage() != other.getPage()) {
                    return false;
                } else if (this.getSize() != other.getSize()) {
                    return false;
                } else if (this.getTotal() != other.getTotal()) {
                    return false;
                } else if (this.getTotalPages() != other.getTotalPages()) {
                    return false;
                } else if (this.isHasNext() != other.isHasNext()) {
                    return false;
                } else {
                    return this.isHasPrevious() == other.isHasPrevious();
                }
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof Page;
    }

    public int hashCode() {

        int result = 1;
        Object $content = this.getContent();
        result = result * 59 + ($content == null ? 43 : $content.hashCode());
        result = result * 59 + this.getPage();
        result = result * 59 + this.getSize();
        long $total = this.getTotal();
        result = result * 59 + (int)($total >>> 32 ^ $total);
        result = result * 59 + this.getTotalPages();
        result = result * 59 + (this.isHasNext() ? 79 : 97);
        result = result * 59 + (this.isHasPrevious() ? 79 : 97);
        return result;
    }

    public String toString() {
        return "Page(content=" + this.getContent() + ", page=" + this.getPage() + ", size=" + this.getSize() + ", total=" + this.getTotal() + ", totalPages=" + this.getTotalPages() + ", hasNext=" + this.isHasNext() + ", hasPrevious=" + this.isHasPrevious() + ")";
    }
}
